package com.leo.ibatis.demo.service.impl;

import java.util.List;

import com.leo.ibatis.demo.base.Service;
import com.leo.ibatis.demo.criteria.OrderstatusCriteria;
import com.leo.ibatis.demo.dao.OrderstatusDao;
import com.leo.ibatis.demo.domain.Orderstatus;
import com.leo.ibatis.demo.service.OrderstatusService;

public class OrderstatusServiceImpl extends Service implements OrderstatusService {

	private OrderstatusDao orderstatusDao;

	public void setOrderstatusDao(OrderstatusDao orderstatusDao) {
		this.orderstatusDao = orderstatusDao;
	}

	public void insert(Orderstatus orderstatus) {
		orderstatusDao.insert(orderstatus);
	}

	public int update(Orderstatus orderstatus) {
		int actualRowsAffected = 0;
		
		int linenum = orderstatus.getLinenum();
		int orderid = orderstatus.getOrderid();

		Orderstatus _oldOrderstatus = orderstatusDao.select(linenum, orderid);
		
		if (_oldOrderstatus != null) {
			actualRowsAffected = orderstatusDao.update(orderstatus);
		}
		
		return actualRowsAffected;
	}

	public int delete(int linenum, int orderid) {
		int actualRowsAffected = 0;
		
		Orderstatus _oldOrderstatus = orderstatusDao.select(linenum, orderid);
		
		if (_oldOrderstatus != null) {
			actualRowsAffected = orderstatusDao.delete(linenum, orderid);
		}
		
		return actualRowsAffected;
	}
	
	public Orderstatus select(int linenum, int orderid) {
		return orderstatusDao.select(linenum, orderid);
	}

	public List<Orderstatus> list(OrderstatusCriteria orderstatusCriteria) {
		return orderstatusDao.list(orderstatusCriteria);
	}
	
	public List<Orderstatus> listOnPage(OrderstatusCriteria orderstatusCriteria) {
		return orderstatusDao.listOnPage(orderstatusCriteria);
	}

}
